<?php

/**
 * The model for setting up a creative
 *
 * @author Andrea Levinge <mslevinge@gmail.com>
 */
class Setup_creative_model extends Model
{
    function Setup_creative_model()
    {
        parent::Model();
    }

	/**
	 * Get all the tags
	 *
	 * @return array
	 */
    function get_tags()
    {
        $query = $this->db->select('*, tags.name as tag_name, tags.id as tag_id, categories.name as cat_name')
                ->from('tags')
                ->join('categories', 'tags.cat_id = categories.id')
                ->get();

        foreach($query->result() as $q)
        {
            $categories[$q->cat_name] = array();
        }

        foreach($query->result() as $q)
        {
            $tags = $q->tag_id . "|" . $q->tag_name;
            array_push($categories[$q->cat_name],$tags);
        }

        return $categories;
    }

	/**
	 * Get all categories
	 *
	 * @return array
	 */
    function get_categories()
    {
        $query = $this->db->get('categories');

        foreach($query->result() as $q)
        {
            $array[$q->id] = $q->name;
        }

        return $array;
    }

	/**
	 * Get all clicks
	 */
    function get_clicks()
    {
        
    }

}